﻿Feature: Caching
	As a component in a system that consumes the Patterns library,
	I want to be able to cache abritrary values, retrieve them from
	any thread, have them expire at predictable times, and receive
	notifications when items I control have expired.

Scenario: Basic Happy Path
	Given I have created a new complex test object
	When I cache the object
	And I retrieve the object
	Then the original object and the cached object should be the same

Scenario: Expired Item
	Given I have created a new complex test object
	When I cache the object using a sliding expiration of 100 milliseconds
	And I wait 100 milliseconds
	And I retrieve the object
	Then the result should be null

Scenario: Sliding Item
	Given I have created a new complex test object
	When I cache the object using a sliding expiration of 100 milliseconds
	And I wait 50 milliseconds
	And I retrieve the non-null object
	And I wait 50 milliseconds
	And I retrieve the non-null object
	And I wait 50 milliseconds
	And I retrieve the non-null object
	Then the original object and the cached object should be the same

Scenario: Expired Notifications
	Given I have created a new complex test object
	When I cache the object using a sliding expiration of 100 milliseconds
	And I add a notification listener for the item
	And I wait 100 milliseconds
	And I retrieve the object
	Then the result should be null
	And I should receive a notification that an item has been removed